const { rejects } = require('assert')
const mysql=require('mysql')
const { resolve } = require('path')

const sqlpool=mysql.createPool({
    user:'root',
    password:"123456",
    host:'localhost',
    database:"users"
})

function exec(sql){
    return new Promise((resolve,rejects)=>{
        sqlpool.query(sql,(err,data)=>{
            if(err){
                rejects(err)
            }else{
                resolve(data)
            }
        })
    })
}

module.exports={exec}